home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ptv1n2.arc / XLAT.ASM < prev   
Assembly Source File  |  1990-06-14  |  914b  |  21 lines

  1. ; Input:  DS:BX = pointer to 256-byte character table, with
  2. ;              characters to be filtered designated by 0 and
  3. ;              other characters designated by themselves.
  4. ;         CX = # of characters in input buffer.
  5. ;         DS:SI = pointer to source buffer to filter from.
  6. ;         ES:DI = pointer to destination buffer to filter to.
  7. ;         The direction flag (DF) must be set to 0 (CLD).
  8. ; Output: DX = # of characters stored in output buffer.
  9. FILTER:
  10.      SUB  DX,DX     ;zero characters transferred counter
  11. FILTER_LOOP:
  12.      LODSB          ;get next character from source buffer
  13.      XLAT           ;look it up in filter table
  14.      AND  AL,AL     ;is it wanted?
  15.      JZ   FILTER_NEXT    ;if not, go to next character
  16.      STOSB          ;it's wanted, store it in output buffer
  17.      INC  DX        ;count this character as usable
  18. FILTER_NEXT:
  19.      LOOP FILTER_LOOP
  20.      RET
  21.